cmake_minimum_required(VERSION 2.8.4)

SET(PRJ_NAME 				dlm-fx)

SET(PRJ_ROOTDIR				${CMAKE_CURRENT_SOURCE_DIR} )

PROJECT(${PRJ_NAME} 		C CXX)

MESSAGE(STATUS "dynamic module function Called by JSON-string.")
MESSAGE(STATUS "Usage for Windows: cmake -DOS_TYPE=Cygwin ..")
MESSAGE(STATUS "Usage for Linux: cmake -DOS_TYPE=Linux ..")

if(OS_TYPE STREQUAL Cygwin)
	MESSAGE(STATUS "@@@ Host platform: Windows Cygwin")
	ADD_DEFINITIONS(-DOS_Cygwin)
endif()

if(OS_TYPE STREQUAL Linux)
	MESSAGE(STATUS "@@@ Host platform: Linux")
	ADD_DEFINITIONS(-DOS_Linux)
endif()

INCLUDE_DIRECTORIES( 
	"${PRJ_ROOTDIR}"
	"${PRJ_ROOTDIR}/POSIX-FIFO"
)

LINK_DIRECTORIES(
	"${PRJ_ROOTDIR}/build"
)
	
	SET(cflags	-std=gnu99)
	ADD_DEFINITIONS(${cflags})


	ADD_EXECUTABLE(dlm-demo1  
		${PRJ_ROOTDIR}/POSIX-FIFO/posixfifo.c 
		${PRJ_ROOTDIR}/dlm.c 
		${PRJ_ROOTDIR}/dlm-test/demo1.c
	)

	ADD_EXECUTABLE(dlm-demo2  
		${PRJ_ROOTDIR}/POSIX-FIFO/posixfifo.c 
		${PRJ_ROOTDIR}/dlm.c 
		${PRJ_ROOTDIR}/dlm-test/demo2.c
	)

	ADD_EXECUTABLE(dlm-demo3 
		${PRJ_ROOTDIR}/POSIX-FIFO/posixfifo.c 
		${PRJ_ROOTDIR}/dlm.c 
		${PRJ_ROOTDIR}/dlm-test/demo3.c
	)

	TARGET_LINK_LIBRARIES(dlm-demo1  
	-ldl -lm -lcJSON
	)
	TARGET_LINK_LIBRARIES(dlm-demo2  
	-ldl -lm -lcJSON
	)
	TARGET_LINK_LIBRARIES(dlm-demo3  
	-ldl -lm -lcJSON
	)

	ADD_LIBRARY(dl1 SHARED ${PRJ_ROOTDIR}/dlm-test/dl1.c)
	ADD_LIBRARY(dl2 SHARED  ${PRJ_ROOTDIR}/dlm-test/dl2.c)
	ADD_LIBRARY(dl3 SHARED  ${PRJ_ROOTDIR}/dlm-test/dl3.c)

	ADD_LIBRARY(cJSON SHARED ${PRJ_ROOTDIR}/cJSON.c)
	TARGET_LINK_LIBRARIES(dl2 -lcJSON)

